﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="menulist.aspx.cs" Inherits="UI.system.page.menu.menulist" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="/js/jquery.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/md5.js"></script>
    <script src="/js/swfupload.js"></script>
    <script src="/system/js/admin.js"></script>
    <script src="/system/layui/layui.js"></script>
    <link rel="stylesheet" href="/system/layui/css/layui.css">
    <link rel="stylesheet" href="/system/css/iframe.css">
</head>
<body>
    <form id="form1" runat="server">
    <div class="layer-toolbar">
        <div class="layer-toolbar-left">
        <a class="layui-btn layui-btn-small" onclick="Save(0,0)">新&nbsp;增</a>
        <a class="layui-btn layui-btn-small" onclick="Btns(0)">按钮列表</a>
        </div>
        <div class="layer-toolbar-right">
            <input id="keyword" type="text" name="title" placeholder="名称" autocomplete="off" class="layui-input" value=""  style="width:150px;" onkeyup='CRM.Enter("#search")'>
            <a id="search" class="layui-btn layui-btn-small layui-btn-normal" onclick="Search()">搜索</a>
            <a class="layui-btn layui-btn-small" onclick="Search()">刷新</a>
        </div>
    </div>
    <div id="iframe" class="layer-iframe">
    <table class="layui-table" lay-data="{id:'mytable', page:false, loading:true, height:'full-90'}">
      <thead>
        <tr>
          <th lay-data="{width:200, templet:'<div>{{# if(d.ParentID!=0){ }} &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font style=\'color:#454545\'>{{d.Name}}</font> {{# }else{ }} <font style=\'font-weight:bold\'>{{d.Name}}</font> {{# } }}</div>'}">菜单名称</th>
          <th lay-data="{width:400,field:'Path'}">菜单路径</th>
          <th lay-data="{width:0,field:'BtnsText'}">按钮</th>
          <th lay-data="{width:100,templet:'<div><input class=\'layui-input tdtext\' value=\'{{d.Sort}}\' onblur=ReSort(this,{{d.ID}},\'menu\') /></div>'}">顺序</th>
          <th lay-data="{width:160, templet:'<div>{{d.IsShow==0?\'隐藏\':\'显示\'}}</div>'}">是否显示</th>
          <th lay-data="{width:155, fixed:'right', templet:'#handler'}">操作</th>
        </tr>
      </thead>
    </table>
    <script type="text/html" id="handler">
        <a class="layui-btn layui-btn-mini" onclick="Save({{d.ID}},0)">编辑</a>
        <a class="layui-btn layui-btn-mini layui-btn-danger" onclick="Delete(this,{{d.ID}})">删除</a>
        {{# if(d.ParentID==0){ }}
        <a class="layui-btn layui-btn-mini layui-btn-normal" onclick="Save(0,{{d.ID}})">子菜单</a>
        {{# } }}
    </script>
    </div>
    </form>
    <script>
        layui.use(["form", "table"], function () {
            var $ = layui.jquery, form = layui.form;
            table = layui.table;
            Init_Pager();
        });

        function Init_Pager(pageindex) {
            var data = {};
            data.act = "Find_Menu";
            data.pageindex = pageindex;
            data.keyword = $("#keyword").val();
            data.sign = GetSign(data.act);
            table.reload('mytable', {
                url: '/tools/Admin.ashx',
                loading: true,
                where: data
            });
        };
        function Save(id,parentid) {
            Ajax.Get("/system/page/menu/menuadd.aspx?id=" + id+"&parentid="+parentid, function (html) {
                var title = id == 0 ? "新增" : "修改";
                window.parent.LayerBox.Show(title + "菜单", html, "590px", "440px", null, function (form) {
                    var data = form;
                    data.act = "Save_Menu";
                    data.id = id;
                    data.btns = CRM.ListValue(".btns input:checked");
                    data.sign = GetSign(data.act);
                    LayerBox.Loading();
                    Ajax.Post("/tools/Admin.ashx", data, function (r) {
                        var json = $.parseJSON(r);
                        if (json.state) {
                            LayerBox.Success(json.msg, 500, function () {
                                LayerBox.Close.ByAll();
                                Init_Pager(1);
                            });
                        }
                        else {
                            LayerBox.Error(json.msg);
                        }
                    });
                });
            });
        };

        function Delete(o, id) {
            LayerBox.Confirm("您确定要删除吗？", function () {
                Delete_Table(o, id, "Delete_Menu");
            });
        };

        function Btns() {
            LayerBox.Loading();
            Ajax.Get("/system/page/menu/btnslist.aspx?v=" + Math.random(), function (html) {
                LayerBox.Close.ByAll();
                window.parent.LayerBox.Detail("按钮列表", html, "680px", "680px");
            });
        };
    </script>
</body>
</html>
